package part2;

import java.util.ArrayList;
import java.util.List;

class Student{
	private String name;
	private int finalExam;
	public Student(String n, int fe){
		name = n;
		finalExam = fe;
	}
	public int finalExam(){
		return finalExam;
	}
	public String name(){
		return name;
	}
	public String toString(){
		return name + " " + finalExam;
	}
}



public class Part2 {

	private static int minFinalExam( List<Student> students ) {
		return minFinalExam( students , 0 );
	}
	private static int maxFinalExam( List<Student> students ) {
		return 0;
	}

	private static int minFinalExam (List<Student> students,int first) {
		int smallest;
		int gradeOfFirst = students.get(first).finalExam();
		if (first == students.size()-1)
			smallest = gradeOfFirst; // the base case
		else { // the general case:
			int minOfRest = minFinalExam(students,first+1);
			if (minOfRest < gradeOfFirst)
				smallest = minOfRest;
			else
				smallest = gradeOfFirst;
		}
		return smallest;
	}
	
	
	public static void main(String[] args) {
		ArrayList<Student> list = new ArrayList<Student>();
		list.add( new Student("Camila" , 153 ));
		list.add( new Student("James" , 146 ));
		list.add( new Student("Jake" , 142 ));
		list.add( new Student("Lindsey" , 145 ));
		list.add( new Student("Jeff" , 135 ));
		list.add( new Student("Brandon" , 143 ));
		
		System.out.println("Lowest score was: " + minFinalExam(list) );
		System.out.println("Highest score was: " + maxFinalExam(list) );
	}
}
